import Vue from 'vue'
import Router from 'vue-router'

// 重写路由方法
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)
import constantRouterMap from './modules/TabBar'//将路由以模块形式构建

const constantRoutes = [
  constantRouterMap
]
const createRouter = () => new Router({
  mode: 'history', // 需要服务支持
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
const router = createRouter()
export default router